package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.TbOfferFamily;
import org.apache.ibatis.annotations.Insert;

/**
 * 家庭成员数据库访问层
 *
 * @author chenyifan
 * @since 2022-06-02 17:50:01
 */
public interface TbOfferFamilyMapper extends BaseMapper<TbOfferFamily> {

    @Insert("INSERT INTO tb_offer_family \n" +
            "(family_id, worker_id, relation_type, member_name, member_address, \n" +
            "work_place, member_phone, update_time, offer_id, already_save) \n" +
            "SELECT \n" +
            "nextval('hrssseq'), a.HC_NO,CASE WHEN b.MemberRelation='' THEN '' WHEN b.MemberRelation is NULL THEN '' ELSE b.MemberRelation END, b.MemberName, b.MemberAddress, \n" +
            "b.MemberWorkPlace, CASE WHEN length(b.MemberTel) != 11 THEN '' ELSE b.MemberTel END, NOW(), b.OfferID, 0 \n" +
            "FROM Offer_Send_Detail a, Offer_FamilyMemberInfo b \n" +
            "WHERE a.id= b.OfferID" )
    void initFamilyRecordFromHrss();
}

